package edu.java.texbooks.tutorial.test02;

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
	Book book1= new Book(100);
	Book book2= new Book(100);
	
	System.out.println("book1 vs. book2 :  " + book1.isLargerThan(book2));
	
	Student pencho= new Student(179);
	Object obj= findLargest(book1, pencho);
	if(obj instanceof Book){
	    System.out.println(((Book) obj).getCountPages());
	}
	if(obj instanceof Student){
	    System.out.println(((Student) obj).getWeight());
	}

    }
    
    public static Object findLargest(Object object1, Object object2) {
	   Relatable obj1 = (Relatable)object1;
	   Relatable obj2 = (Relatable)object2;
	   if ( (obj1).isLargerThan(obj2) > 0)
	      return object1;
	   else 
	      return object2;
	}


}
